package com.shr.exam.xf;

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt() ;
		TreeMap<String, TreeSet<String>> treeMap = new TreeMap<>();
		for(int i = 0;i<count;i++){
			String timeStr = sc.next() ;
			String courseStr = sc.next();
			if(treeMap.containsKey(timeStr))
				treeMap.get(timeStr).add(courseStr);
			else{
				TreeSet<String> set = new TreeSet<>();
				set.add(courseStr) ;
				treeMap.put(timeStr, set) ;
			}
				
		}
		boolean isOk = false ;
		for(Map.Entry<String, TreeSet<String>> entry : treeMap.entrySet()){
			if(entry.getValue().size() > 1){
				isOk = true ;
				System.out.println(entry.getKey());
				for(String s : entry.getValue())
					System.out.println(" " + s);
				System.out.println();
			}
		}
		if(!isOk) System.out.println("YES");
		sc.close();
	}
}
